home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / ABox 1.9.5 / Header Files / ABox.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-26  |  15.8 KB  |  485 lines  |  [TEXT/MMCC]

  1. /*    
  2.     Copyright © 1991-1995 by TopSoft Inc.  All rights reserved.
  3.  
  4.     You may distribute this file under the terms of the TopSoft
  5.     Artistic License, accompanying this package.
  6.     
  7.     This file was developed by George (ty) Tempel in connection with TopSoft, Inc..
  8.     See the Modification History for more details.
  9.  
  10. Product
  11.     About Box
  12.  
  13. FILE
  14.     ABox.h
  15.  
  16. NAME
  17.     ABox.h, part of the ABox project source code
  18.     responsible for handling the AboutBox stuff.
  19.  
  20. DESCRIPTION
  21.     This file contains defines for the about box modules.
  22.     
  23. DEVELOPED BY
  24.     George (ty) Tempel                ttempel@monmouth.com
  25.     All code in this file, and its associated header file was
  26.     Created by George (ty) Tempel in connection with the TopSoft, Inc.
  27.     "FilterTop" application development, except where noted.
  28.  
  29. CARETAKER - George (ty) Tempel <ttempel@monmouth.com>
  30.      Please consult this person for any changes or suggestions to this file.
  31.  
  32. MODIFICATION HISTORY
  33.  
  34.     dd mmm yy    -    xxx    -    patchxx: description of patch
  35.     10 June 94    -    ty    -    Initial Version Created
  36.     20-july-94    -    ty    -    initial version released
  37.     10-mar-95    -    ty    -    1.2 clean up edits for universal headers under CW5.5
  38.     23-may-95    -    ty    -    changes for compatibility with the CodeWarrior CW6
  39.                             release and the associated Universal Headers from Apple:
  40.                             most methods that returned references now have "Ref" at
  41.                             the end of their methods names to prevent possible collisions
  42.                             with datatypes and classes of the same name (older versions
  43.                             of the compiler didn't have a problem with this).
  44.     25-oct-95    -    ty    -    changes for "const" usage under CW7; simplification of Boolean
  45.                             query methods
  46. */
  47.  
  48. /*===========================================================================*/
  49.  
  50. /*========== Exclusion Macros ============*/
  51.  
  52. #pragma    once
  53.  
  54. #ifndef    _ABox_
  55. #define    _ABox_
  56.  
  57.  
  58. /*============ Header Files ==============*/
  59.  
  60.  
  61.  
  62. #include    "ABObject.h"
  63. #include    "ABTopicList.h"
  64.  
  65. #include    "ABUControls.h"
  66. #include    "ABUTextBox.h"
  67. #include    "ABUString.h"
  68. #include    "ABUFonts.h"
  69.  
  70. //    if you define the SPEAK_ERROR symbol,
  71. //    the abox will speak any error messages; if you
  72. //    don't, it'll just beep it's little heart out.
  73.  
  74. #define    SPEAK_ERROR 1
  75.  
  76. #if    SPEAK_ERROR
  77. #include    "ABUEnvSpeechSynth.h"
  78.  
  79. #define    ABERR(pascalString)    { SysBeep(1); if (ABUEnvSpeechSynth::IsPresent()) SpeakString(pascalString);}
  80. #else
  81. #define    ABERR(pascalString) SysBeep(1)
  82. #endif    // SPEAK_ERROR
  83.  
  84.  
  85. /*=========== External Linkage ===========*/
  86.  
  87. /*================ Macros ================*/
  88.  
  89. /*============== Constants ===============*/
  90.  
  91. #define    kABoxWindow                    'ABWn'
  92. #define    kABoxWindowSize                (sizeof(WindowPtr))
  93.  
  94. #define    kABoxHomeFolder                'ABhf'
  95. #define    kABoxHomeFolderSize            (sizeof(FSSpec))
  96.  
  97. #define    kABoxSplashTimeSeconds        'ABst'
  98. typedef    long                        ABoxSplashTimeType;
  99. #define    kABoxSplashTimeSecondsSize    (sizeof(ABoxSplashTimeType))
  100. #define    kABoxNoSplash                    (0)
  101. #define    kABoxWaitForClickSplash            (-1)
  102. #define    kABoxWaitForApplicationSplash    (-2)
  103.  
  104. #define    kABoxNumberOfTopics            'ABNt'
  105. #define    kABoxNumberOfTopicsSize        (sizeof(ABListCount))
  106.  
  107. #define    kABoxFirstTopicNumber        'ABft'
  108. #define    kABoxFirstTopicNumberSize    (sizeof(ABIndex))
  109.  
  110. #define    kABoxCurrentTopic            'ABct'
  111. #define    kABoxCurrentTopicSize        (sizeof(ABTopic))
  112.  
  113. #define    kABoxFirstSlideNumber        'ABfs'
  114. #define    kABoxFirstSlideNumberSize    (sizeof(ABIndex))
  115.  
  116. #define    kABoxAppResFile                'ABrf'
  117. #define    kABoxAppResFileSize            (sizeof(short))
  118.  
  119. #define    kABoxUpdater                'ABup'
  120. #define    kABoxUpdaterSize            (sizeof(UpdateWindowUPP))
  121.  
  122. #define    kABoxModalIndicator            'ABmi'
  123. typedef enum _ABoxModalIndicator
  124. {
  125.     kABoxModal,
  126.     kABoxMoveableModal,
  127.     kABoxModeless
  128. } ABoxModalIndicator;
  129. #define    kABoxModalIndicatorSize        (sizeof(ABoxModalIndicator))
  130.  
  131. #define    kABoxAppNameAndVersion        'ABnv'
  132. #define    kABoxAppNameAndVersionRefSize    (sizeof(Str255))
  133.  
  134. #define    kABoxTextFont                'ABxf'
  135. typedef    short                        ABoxTextFontType;
  136. #define    kABoxTextFontSize            (sizeof(ABoxTextFontType))
  137.  
  138. #define    kABoxTextSize                'ABxs'
  139. typedef    short                        ABoxTextSizeType;
  140. #define    kABoxTextSizeSize            (sizeof(ABoxTextSizeType))
  141.  
  142. #define    kABoxTextFace                'ABxc'
  143. typedef    short                        ABoxTextFaceType;
  144. #define    kABoxTextFaceSize            (sizeof(ABoxTextFaceType))
  145.  
  146.  
  147. #define    kABoxLastEvent                'ABev'
  148. #define    kABoxLastEventSize            (sizeof(EventRecord))
  149.  
  150.  
  151. #define    kABoxListHandle                'ABlh'
  152. #define    kABoxListHandleSize            (sizeof(ListHandle))
  153.  
  154. #define    kABoxWindowTitle            'ABti'
  155. #define    kABoxWindowTitleSize        (sizeof(Str255))
  156.  
  157. #define    kABoxThreadsHandler            'ABTh'
  158. #define    kABoxThreadsHandlerSize        (sizeof(DoThreadsUPP))
  159.  
  160. #define    kABoxInBackground            'ABbg'
  161. #define    kABoxInBackgroundSize        (sizeof(Boolean))
  162.  
  163. #define    kABoxIsFinished                'ABIf'
  164. #define    kABoxIsFinishedSize            (sizeof(Boolean))
  165.  
  166. #define    kABoxReportMemory            'ABrm'
  167. #define    kABoxReportMemorySize        (sizeof(Boolean))
  168.  
  169. #define    kABoxUseSpeechMgr            'ABsm'
  170. #define    kABoxUseSpeechMgrSize        (sizeof(Boolean))
  171.  
  172. #define    kABoxUseDragMgr                'ABdm'
  173. #define    kABoxUseDragMgrSize            (sizeof(Boolean))
  174.  
  175. #define    kABoxUseSoundMgr            'ABzm'
  176. #define    kABoxUseSoundMgrSize        (sizeof(Boolean))
  177.  
  178.  
  179. #define    kAboutBoxWindowKind            (5001)
  180.  
  181. /*================ Enums =================*/
  182.  
  183. /*=============== Structs ================*/
  184.  
  185. /*=============== Typedefs ===============*/
  186.  
  187. //    d26    -    ty
  188. //    used for dispatching the update to another somebody...
  189. //
  190. //    WindowUpdateProcPtr is a pointer to a function that can handle
  191. //    Update events for a given window. This is useful, and indeed is
  192. //    necessary, for handling the updating of other windows (not ours)
  193. //    during ModalDialog event processing and Baloon Help.
  194. //
  195. typedef    void (*WindowUpdateProcPtr)(WindowPtr window);
  196.  
  197. #if GENERATINGCFM
  198.     // powerpc stuff
  199.     typedef UniversalProcPtr UpdateWindowUPP;
  200. #else
  201.     typedef WindowUpdateProcPtr UpdateWindowUPP;
  202. #endif
  203.  
  204. #define        kABbadUpdateWindowUPP            ((UpdateWindowUPP)NULL)
  205.  
  206. //    there is no RESULT_SIZE in the following UPP enumeration
  207. //    since the WindowUpdateProcPtr is a void function
  208. enum {
  209.     windowUpdateProcInfo = kCStackBased
  210.         |    STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(WindowPtr)))
  211. };
  212.  
  213. //    if USEROUTINEDESCRIPTORS is defined by the environment then universal
  214. //    proc ptr's will be generated in anticipation of possible PPC execution,
  215. //    otherwise all of the following defines and typedefs become the good
  216. //    old familiar 68k style information from pre-PowerMac days.
  217. //
  218. //    CallWindowUpdateProc() is a macro used to invoke the WindowUpdateProcPtr
  219. //    (UpdateWindowUPP) via univesral proc pointers.
  220. //
  221. //    NewWindowUpdateProc() is a macro used to dynamically create a
  222. //    universal WindowUpdateProcPtr (UpdateWindowUPP)
  223. //
  224. #if    GENERATINGCFM
  225.     //    powerpc stuff
  226.     #define NewWindowUpdateProc(userRoutine)        \
  227.             (UpdateWindowUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), windowUpdateProcInfo, GetCurrentISA())
  228.             
  229. #else        //    not using the universal PPC style proc pointers
  230.  
  231.     #define NewWindowUpdateProc(userRoutine)        \
  232.             (UpdateWindowUPP)(userRoutine)
  233.         
  234. #endif    //    GENERATINGCFM
  235.  
  236.  
  237. #if    GENERATINGCFM
  238.     #define CallWindowUpdateProc(userRoutine, windowPtr)        \
  239.             CallUniversalProc((UniversalProcPtr)(userRoutine), windowUpdateProcInfo, (windowPtr))
  240.     
  241. #else        //    not using the universal PPC style proc pointers
  242.  
  243.     #define CallWindowUpdateProc(userRoutine, windowPtr)        \
  244.             (*(userRoutine))((windowPtr))
  245. #endif    //    GENERATINGCFM
  246.  
  247.  
  248. //=============
  249.  
  250. //    used for yielding time to other threads...
  251. //
  252. //    DoThreadsProcPtr is a pointer to a Pascal-style parameter-less function 
  253. //    that returns a type of OSErr. It will be used as a means to
  254. //    handle yielding time to other threads, whether via the thread mgr or
  255. //    the older and not-really-supported threads pkg.
  256. //
  257. typedef    pascal OSErr (*DoThreadsProcPtr)(void);
  258.  
  259. #if    GENERATINGCFM
  260.     typedef    UniversalProcPtr    DoThreadsUPP;
  261. #else        //    not using the universal PPC style proc pointers
  262.  
  263.     typedef DoThreadsProcPtr     DoThreadsUPP;
  264.  
  265. #endif    //    GENERATINGCFM
  266.  
  267. //    there is no RESULT_SIZE in the following UPP enumeration
  268. //    since the DoThreadsProcPtr is a void function
  269. //
  270. //    there are no parameters in the following UPP enumeration since
  271. //    the DoThreadsProcPtr has none.
  272. enum {
  273.     doThreadsProcPtrInfo = kPascalStackBased
  274.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  275. };
  276.  
  277. //    if GENERATINGCFM is defined by the environment then universal
  278. //    proc ptr's will be generated in anticipation of possible PPC execution,
  279. //    otherwise all of the following defines and typedefs become the good
  280. //    old familiar 68k style information from pre-PowerMac days.
  281. //
  282. //    CallDoThreadsUpdateProc() is a macro used to invoke the DoThreadsProcPtr
  283. //    via univesral proc pointers.
  284. //
  285. //    NewDoThreadsProc() is a macro used to dynamically create a
  286. //    universal DoThreadsProcPtr
  287. //
  288. #if    GENERATINGCFM
  289. #define NewDoThreadsProc(userRoutine)        \
  290.         (UpdateWindowUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), doThreadsProcPtrInfo, GetCurrentISA())
  291.         
  292. #else        //    not using the universal PPC style proc pointers
  293.  
  294. #define NewDoThreadsProc(userRoutine)        \
  295.                 (DoThreadsUPP)(userRoutine)
  296.         
  297. #endif    //    GENERATINGCFM
  298.  
  299. #if    GENERATINGCFM
  300. #define CallDoThreadsUpdateProc(userRoutine)        \
  301.         CallUniversalProc((UniversalProcPtr)(userRoutine), doThreadsProcPtrInfo)
  302.  
  303. #else        //    not using the universal PPC style proc pointers
  304.  
  305. #define CallDoThreadsUpdateProc(userRoutine)        \
  306.                 (*(userRoutine))()
  307.         
  308. #endif    //    GENERATINGCFM
  309.  
  310.  
  311.  
  312. /*=========== Class Definitions ==========*/
  313.  
  314. #define    kABoxSuperProperty    ABObject
  315. class    ABox : public ABObject, 
  316.                 ABUControls
  317. #ifdef    SPEAK_ERROR
  318.             , ABUEnvSpeechSynth
  319. #endif    // SPEAK_ERROR
  320. {
  321.     public:
  322.                         ABox(void);
  323.         virtual            ~ABox(void);
  324.     
  325.             OSErr    GetProperty (ABProperty prop, void *ptr, long *ptrSize);
  326.             OSErr    SetProperty (ABProperty prop, void *ptr, long ptrSize);
  327.         
  328.             OSErr    Draw(WindowPtr window);
  329.             OSErr    Update(WindowPtr window);
  330.             Boolean    Event(EventRecord *event);
  331.             OSErr    Stop(void);
  332.             OSErr    Close(void);
  333.  
  334.             GrafPtr    GetWindow(void) const { return this->OurWindowRef(); }
  335.  
  336.             Boolean    IsInBackground(void) const { return this->InBackgroundFlagRef() == true; }
  337.             Boolean IsInForeground(void) const { return ! this->IsInBackground(); }
  338.             
  339.             Boolean    HasWindowName(void) const { return this->WindowNameRef() != NULL; }
  340.             
  341.             Boolean IsWindowUp(void) const { return this->WindowUpFlagRef() == true; }
  342.             
  343.             Boolean    IsModal(void) const { return this->ModalIndicatorRef() == kABoxModal; }
  344.             Boolean    IsMoveableModal(void) const { return this->ModalIndicatorRef() == kABoxMoveableModal; }
  345.             Boolean    IsModeless(void) const { return this->ModalIndicatorRef() == kABoxModeless; }
  346.             
  347.             Boolean IsNotSplashScreen(void) const { return this->SplashTimeRef() == kABoxNoSplash; }
  348.             Boolean    IsClickSplash(void) const { return this->SplashTimeRef() == kABoxWaitForClickSplash; }
  349.             Boolean IsApplicationSplash(void) const { return this->SplashTimeRef() == kABoxWaitForApplicationSplash; }
  350.             Boolean IsSplashScreen(void) const { return ! this->IsNotSplashScreen(); }
  351.             
  352.     protected:
  353.     static    pascal    void    DrawDialogItem(DialogPtr dialog, short itemNo);
  354.     static    pascal Boolean    ModalEventFilter(DialogPtr dialog, EventRecord *event, short *item);
  355.  
  356.             OSErr    ToForeground(void);
  357.             OSErr    ToBackground(void);
  358.             
  359.             OSErr    ChangeControls(void);
  360.             OSErr    BuildABox (void);
  361.             OSErr    CreateAndFillTopicList (void);
  362.             OSErr    ProcessItemHit (EventRecord *eventRec, short itemNo);
  363.             Boolean    Splash (EventRecord *eventRec);
  364.             Boolean    HandleEvent (EventRecord *eventRec, short itemNo);
  365.             OSErr    DoThreads(void);
  366.  
  367.             void    ReportMemory(void);
  368.             
  369.     private:
  370.         //    these elements are caller available properties...
  371.                 FSSpecPtr            mHomeFolder;
  372.                 ABIndex                mFirstTopic;
  373.                 ABIndex                mFirstSlide;
  374.                 long                mSplashTime;
  375.                 short                mCallerResFile;
  376.                 UpdateWindowUPP        mUpdater;
  377.                 ABoxModalIndicator    mModalIndicator;
  378.                 StringPtr            mAppNameAndVersionRef;
  379.                 StringPtr            mWindowName;
  380.                 short                mTextFont;
  381.                 short                mTextSize;
  382.                 short                mTextFace;
  383.                 ListHandle            mListHandle;
  384.                 EventRecord            mLastEvent;
  385.                 Boolean                mInBackgroundFlag;
  386.                 DoThreadsUPP        mThreadsHandler;
  387.                 Boolean                mReportMemoryFlag;
  388.                 Boolean                mUseSpeechMgrFlag;
  389.                 Boolean                mUseSoundMgrFlag;
  390.                 Boolean                mUseDragMgrFlag;
  391.                 
  392.         //    these elements are strictly internal items...
  393.                 short                mDialogID;
  394.                 ABTopicList*        mTopics;
  395.                 ABUEnv*                mThreadsInfo;
  396.                 Boolean                mWindowUpFlag;
  397.                 ModalFilterUPP        mModalUPP;
  398.                 
  399.                 FSSpecPtr&            HomeFolderRef(void)      { return this->mHomeFolder; }
  400.                 FSSpecPtr const&    HomeFolderRef(void) const { return this->mHomeFolder; }
  401.  
  402.                 ABIndex&            FirstTopicRef(void)      { return this->mFirstTopic; }
  403.                 ABIndex const&        FirstTopicRef(void) const { return this->mFirstTopic; }
  404.  
  405.                 ABIndex&            FirstSlideRef(void)      { return this->mFirstSlide; }
  406.                 ABIndex const&        FirstSlideRef(void) const { return this->mFirstSlide; }
  407.  
  408.                 long&                SplashTimeRef(void)      { return this->mSplashTime; }
  409.                 long const&            SplashTimeRef(void) const { return this->mSplashTime; }
  410.  
  411.                 short&                CallerResFileRef(void)      { return this->mCallerResFile; }
  412.                 short const&        CallerResFileRef(void) const { return this->mCallerResFile; }
  413.  
  414.                 UpdateWindowUPP&    UpdaterRef(void)      { return this->mUpdater; }
  415.                 UpdateWindowUPP const&    UpdaterRef(void) const { return this->mUpdater; }
  416.  
  417.                 ABoxModalIndicator&    ModalIndicatorRef(void)      { return this->mModalIndicator; }
  418.                 ABoxModalIndicator const&    ModalIndicatorRef(void) const { return this->mModalIndicator; }
  419.  
  420.                 StringPtr&            AppNameAndVersionRef(void)      { return this->mAppNameAndVersionRef; }
  421.                 StringPtr const&    AppNameAndVersionRef(void) const { return this->mAppNameAndVersionRef; }
  422.  
  423.                 StringPtr&            WindowNameRef(void)      { return this->mWindowName; }
  424.                 StringPtr const&    WindowNameRef(void) const { return this->mWindowName; }
  425.  
  426.                 short&                TextFaceRef(void)      { return this->mTextFace; }
  427.                 short const&        TextFaceRef(void) const { return this->mTextFace; }
  428.  
  429.                 short&                TextFontRef(void)      { return this->mTextFont; }
  430.                 short const&        TextFontRef(void) const { return this->mTextFont; }
  431.  
  432.                 short&                TextSizeRef(void)      { return this->mTextSize; }
  433.                 short const&        TextSizeRef(void) const { return this->mTextSize; }
  434.  
  435.                 ListHandle&            ListHandleRef(void)      { return this->mListHandle; }
  436.                 ListHandle const&    ListHandleRef(void) const { return this->mListHandle; }
  437.  
  438.                 EventRecord&        LastEventRef(void)      { return this->mLastEvent; }
  439.                 EventRecord const&    LastEventRef(void) const { return this->mLastEvent; }
  440.  
  441.                 Boolean&            InBackgroundFlagRef(void)      { return this->mInBackgroundFlag; }
  442.                 Boolean const&        InBackgroundFlagRef(void) const { return this->mInBackgroundFlag; }
  443.  
  444.                 DoThreadsUPP&        ThreadsHandlerRef(void)      { return this->mThreadsHandler; }
  445.                 DoThreadsUPP const&    ThreadsHandlerRef(void) const { return this->mThreadsHandler; }
  446.  
  447.                 Boolean&            ReportMemoryFlagRef(void)      { return this->mReportMemoryFlag; }
  448.                 Boolean const&        ReportMemoryFlagRef(void) const { return this->mReportMemoryFlag; }
  449.  
  450.                 Boolean&            UseSpeechMgrFlagRef(void)      { return this->mUseSpeechMgrFlag; }
  451.                 Boolean const&        UseSpeechMgrFlagRef(void) const { return this->mUseSpeechMgrFlag; }
  452.  
  453.                 Boolean&            UseSoundMgrFlagRef(void)      { return this->mUseSoundMgrFlag; }
  454.                 Boolean const&        UseSoundMgrFlagRef(void) const { return this->mUseSoundMgrFlag; }
  455.  
  456.                 Boolean&            UseDragMgrFlagRef(void)      { return this->mUseDragMgrFlag; }
  457.                 Boolean const&        UseDragMgrFlagRef(void) const { return this->mUseDragMgrFlag; }
  458.                 
  459.                 short&                DialogIDRef(void)      { return this->mDialogID; }
  460.                 short const&        DialogIDRef(void) const { return this->mDialogID; }
  461.  
  462.                 ABTopicList*&        TopicsRef(void)      { return this->mTopics; }
  463.                 ABTopicList* const&    TopicsRef(void) const { return this->mTopics; }
  464.  
  465.                 GrafPtr&            WindowRef(void)      { return this->OurWindowRef(); }
  466.                 GrafPtr const&        WindowRef(void) const { return this->OurWindowRef(); }
  467.  
  468.                 ABUEnv*&            ThreadsInfoRef(void)      { return this->mThreadsInfo; }
  469.                 ABUEnv* const&        ThreadsInfoRef(void) const { return this->mThreadsInfo; }
  470.  
  471.                 Boolean&            WindowUpFlagRef(void)      { return this->mWindowUpFlag; }
  472.                 Boolean const&        WindowUpFlagRef(void) const { return this->mWindowUpFlag; }
  473.  
  474.                 ModalFilterUPP&        ModalUPPRef(void)      { return this->mModalUPP; }
  475.                 ModalFilterUPP const&    ModalUPPRef(void) const { return this->mModalUPP; }
  476.                 
  477. };
  478.  
  479.  
  480. /*========== Function Prototypes =========*/
  481.  
  482.  
  483. #endif    // _ABox_
  484.  
  485.